<template>
    <div class="wrapper frame-wrapper">
        <div
            class="header"
            @click="doDebug"
        >
            {{ title }}
        </div>
        <HeadStep
            v-if="steps.length > 0"
            class="head-step"
            :steps="steps"
            :current-index="currentIndex"
        />
        <FrameContent
            v-if="errMsg"
            foot-hide
        >
            <div class="empty">
                <img
                    :src="Img_Default"
                    alt=""
                />
                <p>{{ errMsg }}</p>
            </div>
        </FrameContent>
        <slot v-else></slot>
    </div>
</template>
<script>
import Img_Default from '@/assets/images/default.png';
import HeadStep from '@/components/HeadStep';

export default {
    name: 'Frame',
    components: { HeadStep },
    props: {
        // 当前聚焦的下标值
        currentIndex: {
            type: Number,
            default: -1,
        },
        title: {
            type: String,
            default: '',
        },
        // 内容数组
        steps: {
            type: Array,
            default: () => [],
        },
        errMsg: {
            type: String,
            default: '',
        },
    },
    data() {
        return {
            Img_Default,

            vConsoleTimer: null,
            vConsoleCounter: 0,
        };
    },
    mounted() {},
    methods: {
        doDebug() {
            this.vConsoleCounter++;
            clearTimeout(this.vConsoleTimer);
            this.vConsoleTimer = setTimeout((_) => {
                if (this.vConsoleCounter >= 5) {
                    let dom = document.querySelector('.vc-switch');
                    let style = dom.getAttribute('style') + 'right: 0px !important;';
                    dom.setAttribute('style', style);
                }
                this.vConsoleCounter = 0;
            }, 500);
        },
    },
};
</script>

<style lang="less">
.vc-switch {
    //   right: 200% !important;
}
</style>
<style lang="less" scoped>
dl {
    font-size: 15px;
    line-height: 30px;
}
dt {
    color: #333;
    font-weight: 600;
}
dd {
    color: #666;
}

.frame-wrapper {
    background: url('~@/assets/images/banner.png') no-repeat;
    background-size: 100% auto;
}

.header {
    width: 100%;
    padding-top: 18px;
    margin-bottom: 20px;
    text-align: center;
    color: #fff;

    .header-score {
        margin-bottom: 6px;
        font-size: 50px;
        line-height: 50px;
    }

    .header-title {
        padding-top: 20px;
        margin-bottom: 10px;
        font-size: 24px;
        line-height: 24px;
        letter-spacing: 1px;
        text-shadow: 2px 2px 2px #005bbc99;
    }

    .header-subtitle {
        padding-top: 20px;
        font-size: 18px;
        text-shadow: -2px -2px 2px #005bbc99;
        line-height: 26px;
        letter-spacing: 2px;
    }

    .header-des {
        font-size: 12px;
    }
}

.head-step {
    margin: 0 16px;
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    height: 100%;
    text-align: center;

    img {
        width: 200px;
        margin-bottom: 16px;
    }

    p {
        height: 45px;
        font-size: 15px;
        color: #333;
        line-height: 45px;
    }
}
</style>
